package org.ihelpuoo.weboo.module;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ihelpuoo.core.Nut;

public abstract class WebooServlet extends HttpServlet
{
	protected Nut			nut;
	protected ModuleManager	moduleManager;
	protected WebooConfig	webooConfig;

	@Override
	public void init() throws ServletException
	{
		nut = Nut.me(getServletContext());
		moduleManager = ModuleManager.me(this.getServletContext());
		webooConfig = WebooConfig.me(getServletContext());
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{
		doHTTP(request,response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{
		doHTTP(request,response);
	}

	protected void doHTTP(HttpServletRequest request, HttpServletResponse response)
	{
		webooConfig.initContextPath(request);
	}

}
